import React from 'react'
// ===================================================================== Temp
import Table from '#cpt/temp/Table'
import TableControls from '#cpt/temp/TableControls'
import Confirm from '#cpt/temp/Confirm'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Page = $Lazy.load(()=>import('#tp/page/page-container'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '打印机名称',		name: 'printer_name' },
		],
		// 提交表单列表
		formData : [
			{ label: '打印机名称',		name: 'printer_name', 		required:true, full:true },
			{ label: '打印机型号',		name: 'printer_model', 		required:true, full:true },
			{ label: '打印机类型',		name: 'printer_type', 		required:true, full:true, type:'select',idStr:'code'},
			{ label: '打印机代码',		name: 'printer_code', 		required:true, full:true },
		]
	}
	
	model = {}
	
	componentDidMount(){
		this.fetch()
	}
	
	// paging
	fetch = () => $fn.fetch.call(this,'st-view/userlist')
	
	// 表单
	cols = [
		{ title: '视图名称', 	dataIndex: 'dc_name', 		width:200 },
		{ title: '视图代码', 	dataIndex: 'dc_code', 		width:200 },
		{ title: '视图描述', 	dataIndex: 'dc_desc', 		width:200 },
		{ title: '排序', 		dataIndex: 'sort', 			...$fn.table.num },
		{ title: '是否默认', 	dataIndex: 'is_default', 	width:80, render: text => +text === 1 ? '是' : '否' },
		TableControls.controls.call(this,{width:80})
	]
	// 表格操作按钮
	table_controls = (text,{ uuid }) => {
		return [
			Confirm.call(this,'绑定', 'st-view/bindView', { param: uuid })
		]
	}
	
	render(){
		return (
			<>
				<Page title='绑定视图'>
					<div className='h10'></div>
					{/* 表格 */}
					{ Table.call(this) }
				</Page>
			</>
		)
	}
}

export default Index